﻿<!DOCTYPE html>
<!--隔离盲板动态管理状态记录表-->
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

</head>
<body>
    <div id="app" v-cloak class="popupW150">
        <el-form label-position="right" :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="150px"
                 size="mini">
            <el-row>
                <el-col :span="11">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input type="text" v-model="Form.GoodsName" autocomplete="off" size="mini">
                                <template slot="prepend">
                                    {{RestrictedObject.GoodsName+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="11" :offset="2">
                    <el-form-item :label="RestrictedObject.Quantity+mark.m" class="inputTextarea">
                        <el-input-number v-model="Form.Quantity" @change="handleChange" :min="1"></el-input-number>
                    </el-form-item>
                </el-col>
                <el-col :span="11" >
                    <el-form-item :label="RestrictedPerson.IntoRestrictedSpaceTime+mark.m" prop="InstallationTime">
                        <el-date-picker v-model="Form.IntoRestrictedSpaceTime"
                                        type="datetime"
                                        placeholder="选择日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
                <el-col :span="11" :offset="2">
                    <el-form-item :label="RestrictedPerson.OutSpaceTime+mark.m" prop="ExtractionTime">
                        <el-date-picker v-model="Form.OutSpaceTime"
                                        type="datetime"
                                        placeholder="选择日期时间">
                        </el-date-picker>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnConfirm}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>

    </div>
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    GoodsName: "",
                    Quantity: "",
                    IntoRestrictedSpaceTime: "",
                    OutSpaceTime: "",
                    Pid:"",
                },
                //表单验证
                rules: {
                    GoodsName: [
                        verification.NotNull,
                        { pattern: verification.StringLengthAtoB.t.format(1, 50), message: verification.StringLengthAtoB.m.format(5, 10), trigger: 'blur' }
                    ],
                    IntoRestrictedSpaceTime: [
                        verification.NotNull,
                   
                    ],
                    OutSpaceTime: [
                        verification.NotNull,
                    
                    ]
                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                handleChange: function (value) {
                    console.log(value);
                },
                getTime: function (dt) {
                    var year = dt.getFullYear(); //年
                    var month = dt.getMonth() + 1; //月
                    var date = dt.getDate(); //日
                    month = month < 10 ? "0" + month : month;
                    date = date < 10 ? "0" + date : date;
                    var str = year + "-" + month + "-" + date;
                    return str;
                },
                //提交数据
                onSubmitForm: function () {       
                    var bool = true;
                    var list = parent.app.Form.RestrictedObject;
                    for (var i = 0; i < list.length; i++) {
                        if (list[i].id == this.id) {
                            list[i].GoodsName = this.Form.GoodsName,
                                list[i].Quantity = this.Form.Quantity,
                            list[i].IntoRestrictedSpaceTime = this.getTime(new Date(this.Form.IntoRestrictedSpaceTime)),
                            list[i].OutSpaceTime = this.getTime(new Date(this.Form.OutSpaceTime)),
                            bool = false;
                        }
                    }
                    if (bool) {
                        list.push({
                            GoodsName: this.Form.GoodsName,
                            Quantity: this.Form.Quantity,
                            IntoRestrictedSpaceTime: this.getTime(new Date(this.Form.IntoRestrictedSpaceTime)) ,
                            OutSpaceTime: this.getTime(new Date(this.Form.OutSpaceTime)), 
                            id: Mock.Random.id(),
                            Pid: this.id,
                            });
                    }
                    parent.app.ListItem.dialogVisible = false;
                },
                getData: function () {
                    getData(this, '/api/ConfinedSpaceWorkSafety/getRestrictedObjectItem?id=' + this.id);
                }
            },
            mounted: function () {
                this.id = getUrlParam("id");
                this.getData();
            }
        });
    </script>
</body>

</html>